Like Adak said there a lot of ways to do this program
So here's my approach
Thanks for all your help!
Code:
/************************************************************************** * exp7a.c
*
* NES113 - 4C
* ACOSTA, Arbyn M.
*
* A program that will accept a user input of not more than 50 characters
* and find set of letters that will produce the string “just do it” then
* output the string “just do it” if the letters in the entered string can
* be used to produce the desired string
*************************************************************************/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int
main(void)
{
char string[51], just_do_it[] = "JUSTDOIT";
int correct = 0;
fgets(string, 51, stdin);
// capitalize the input of the user
for (int i = 0, end = strlen(string); i < end; i++)
string[i] = toupper(string[i]);
// iterate over the input for input checking
for (int i = 0, end = strlen(string); i < end; i++)
{
for (int j = 0; j < 8; j++)
{
// checks if a letter matched and its not a space
if (string[i] == just_do_it[j] && just_do_it[j] != ' ' && string[i] != ' ')
{
correct++;
// replace the letter with space to avoid redudancy
just_do_it[j] = ' ';
break;
}
}
}
if (correct == 8)
printf("\nJust do it\n");
else
printf("\nThe word just do it cannot be found on the sentence you type.\n");
return 0;
}